" =========================================================================
" File: my vim configure file
" Author: yongliang <neeyongliang@gmail.com>
" Changelog:
"   2022.12.10 First release
"   2022.12.12 Add copy, paste and cut key bindings
" ========================================================================

" It is recommended to make changes after sourcing debian.vim since it alters
" the value of the 'compatible' option.

runtime! debian.vim

" Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc.
" This happens after /etc/vim/vimrc(.local) are loaded, so it will override
" any settings in these files.
let g:skip_defaults_vim = 1

" ========== Plug ==========

" Install vim-plug
" cd /usr/share/vim/vim81/autoload
" sudo wget http://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" sudo mkdir -p /usr/share/vim/plug

" For Linux
call plug#begin("/usr/share/vim/plug")
" For mac
" call plug#begin()
" Plug 'http://github.com/tomasiser/vim-code-dark.git'
" Plug 'http://github.com/liuchengxu/vim-better-default.git'
Plug 'http://gitee.com/neeyongliang/mirror-vim-better-default.git'
Plug 'http://github.com/ntpeters/vim-better-whitespace.git'
Plug 'http://github.com/liuchengxu/vim-which-key.git'
call plug#end()

" :PlugInstall
" :PlugUpdate
" :PlugClean
" :PlugStatus

" ========== Settings =========
if has("syntax")
  syntax on
endif

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
  set fileencodings=ucs-bom,utf-8,gbk18030,latin1
endif

" set backspace=indent,eol,start
if has('mouse')
  set mouse=a
  set mousemodel=popup
endif

colorscheme codedark
filetype plugin indent on
set autowrite

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif


" for other

" =========== Other ==========


" ========== Keys ==========
" for vim-which-key
set nocompatible
let g:mapleader=" "
let g:maplocalleader = ","

nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<cr>
vnoremap <silent> <localleader> :<c-u>WhichKey ','<cr>
let g:which_key_map = {}

let g:which_key_map.f = { 'name' : '+file' }

nnoremap <silent> <leader>fs :update<CR>
let g:which_key_map.f.s = 'save-file'

nnoremap <silent> <leader>fd :e $MYVIMRC<CR>
let g:which_key_map.f.d = 'open-vimrc'

nnoremap <silent> <leader>oq  :copen<CR>
nnoremap <silent> <leader>ol  :lopen<CR>
let g:which_key_map.o = {
      \ 'name' : '+open',
      \ 'q' : 'open-quickfix',
      \ 'l' : 'open-locationlist',
      \ }

call which_key#register('<Space>', 'g:which_key_map')

if exists('+colorcolumn')
   let &colorcolumn="100"
endif

" Add Copy, Paste, and Cut
vnoremap <C-x> "+x
vnoremap <C-S-v> "+p
vnoremap <C-S-c> "+y
